#ifndef __DYNAMICARRAY_H_
#define __DYNAMICARRAY_H_
#include<stdbool.h>

#define ElementType void*//用宏实现便于代码变换  //万能数组

//c语言保证数据安全的写法
//首先在头文件只写声明，定义写在源文件，外部使用的时候只能用指针，不能用变量
struct DynamicArray; //给结构体的前置声明

typedef struct Student Stu;

typedef struct DynamicArray DArray;

DArray *InitDArry(int capacity);
void InsertTail(DArray *array, ElementType element);

void RemoveByIndex(DArray *array,int index);
void RemoveByElement(DArray *array, ElementType element);
void FreeDArray(DArray *array, void(*Free)(ElementType));
void PrintDArray(DArray *array, void (*print)(ElementType));
ElementType *FindByElement(DArray *array,ElementType element);

void Sort(DArray *a, bool (*Compare)(ElementType, ElementType));

Stu* Search(DArray *a, ElementType name);

bool CompareName(void *p1, void *p2);

bool GreatName(void *p1, void *p2);

bool GreatName2(void *p1, void *p2);

bool CompareID(void *p1, void *p2);

void printStu(void *str);

void FreeStu(void *ptr);

Stu* InitStu(int id, const char *name);

#endif